<template>
  <div class="rankList">
    <dl>
      <van-sticky :offset-top="0">
        <dt v-show="show" @click="plAllMusic()">
          <span class="iconfont icon-bofang1"></span>播放全部<i>(共{{ songs.length }}首)</i>
        </dt>
      </van-sticky>
      <dd v-for="(item, index) in songs" :key="item.id">
        <span v-show="show" :class="{ active: index < 3 }">{{
        index + 1 < 10 ? `0${index + 1}` : `${index + 1}` }}</span>
            <div>
              <h4>{{ item.name }}</h4>
              <h6>{{ item.ar[0].name }}</h6>
            </div>
            <i v-show="{indexShow:indexShow!=index}" class="iconfont icon-bofang2" @click="plMusic(index)"></i>
            <!-- <img v-show="{ indexShow :indexShow==index}" src="@/assets/img/load.gif" alt="" class="loadimg"> -->
      </dd>
    </dl>
  </div>
</template>

<script>
import { mapMutations } from 'vuex';
export default {
    props: ["songs"],
    data() {
        return {
            show: true,
          indexShow:false,

            lists: {
                tracks: [],
                coverImgUrl: null,
            },

        };
    },
    methods: {
        ...mapMutations(['updatePlayer','updatePlayerrListIndex']),
        plMusic(index){ 
          this.indexShow=index
          console.log(index);
            this.updatePlayer(this.songs)
            this.updatePlayerrListIndex(index)
            },
      plAllMusic(){
        this.updatePlayer(this.songs)
        this.updatePlayerrListIndex(0)
      }

    },
    mounted() {
        //如果不是hotSongList路由组件,隐藏序号
      if (this.$route.path == "/search" || this.$route.path == "/recentPlay") {
            this.show = false;
        }
   

    },
}
</script>
<style lang="scss" scoped>


// 歌曲列表样式
.rankList {
  background-color: #ffffff;
  margin-top: 20px;
  border-radius: 8px 8px 0px 0px;
  dt {
    height: 36px;
    line-height: 36px;
    font-size: 17px;
    color: #2d2f2e;
    font-weight: bold;
    background-color: #ffffff;
    span {
      display: inline-block;
      height: 20px;
      width: 20px;
      border-radius: 50%;
      font-size: 9px;
      text-align: center;
      line-height: 20px;
      margin-left: 12px;
      vertical-align: 2px;
      margin-right: 9px;
      background-color: #ff4a3c;
    }
    .icon-bofang1 {
      color: #fff;
    }

    i {
      font-size: 14px;
      color: #6b6c6c;
      vertical-align: 1px;
      font-weight: normal;
      font-style: normal;
    }
  }

  dd {
    display: flex;
    height: 53px;
    border-top: 1px solid #e3e3e3;
    align-items: center;
z-index: -1;
    span {
      height: 53px;
      width: 35px;
      line-height: 53px;
      text-align: center;
      font-size: 16px;
      color: #6b6c6c;
    }

    div {
      flex: 1;
      padding-left: 10px;
      h4 {
        height: 20px;
        line-height: 20px;
        margin-top: 10px;
        font-size: 17px;
        color: #222725;
        overflow: hidden;
      }

      h6 {
        height: 15px;
        line-height: 15px;
        font-size: 12px;
        color: #898a8a;
      }
    }

    i {
      color: #b3b3b3;
      font-size: 30px;
      padding-right: 10px;
    }
  }

  .active {
    font-weight: bold;
    color: #df3436;
  }
}
.loadimg{
  width: 20px;
  margin-right: 20px;
}
</style>